import request from "@/utils/request"
/**设置页面 大小卡片视图全部包含 */
export const uSelectMyAllDevSetAndStatus = (params: {userId: string | number}) =>
	request.get<Setting.AllDevSetAndStatus>("/user/uSelectMyAllDevSetAndStatus", params)

/**设备功能列表 */
export const selectDevFunBydDevId = (params: {devId: string | number}) =>
	request.get<Setting.DevFun[]>("/user/selectDevFunBydDevId", params)

/**设备状态分析 含水质情况，设备状态，运行时间，在线率，正常率，异常日志数量 */
export const uSelectDevStatus = (params: {devId: string | number}) =>
	request.get<Setting.DevStatus>("/user/uSelectDevStatus", params)

/**设置页面 大小卡片视图全部包含 */
export const uSelectDevLogByPage = (params: {
	devId: string | number
	devLogTypeCode: string
	startDate: string
	endDate: string
	page: number
}) =>
	request.get<PagingResponse<Setting.LogData>>(
		"/user/uSelectDevLogByPage",
		Object.assign(params, {size: 20})
	)

/**单设备产品资料 */
export const uSelectDevProductFile = (params: {devId: string | number}) =>
	request.get<Setting.FileData[]>("/user/uSelectDevProductFile", params)

/**查询单设备 我的分享详情 */
export const uSelectMyShareData = (params: {devId: string | number; userId: string | number}) =>
	request.get<Setting.MyShareData>("/user/uSelectMyShareData", params)

/**查询单设备 分享给了那些用户 */
export const uSelectDevShareData = (params: {devId: string | number; userId: string | number}) =>
	request.get<Setting.DevShareData>("/user/uSelectDevShareData", params)

/**查询 其他用户分享给我的所有的设备*/
export const uSelectMyShareLinkDev = (params: {userId: string | number}) =>
	request.get<Setting.ShareData[]>("/user/uSelectMyShareLinkDev", params)

/**分享设备 */
export const uShareMyDev = (params: {shareUserPhone: string; devId: string | number}) =>
	request.get<null>("/user/uShareMyDev", params)

/**取消分享设备 */
export const uCancelShareDev = (params: {userDevId: number | string}) =>
	request.get<null>("/user/uCancelShareDev", params)

/**设备基本信息 */
export const uSelectDevStatusAndSimpleData = (params: {devId: string | number}) =>
	request.get<Setting.DevBaseInfo>("/user/uSelectDevStatusAndSimpleData", params)

/**修改设备基本信息 */
// { devBaseDataId: number, devBaseDataValue: string }[]
export const uEditDevBaseData = (params: {
	devId: string | number
	// devBaseDataList: Setting.BaseInfoData[]
	devName: string | null
	province: string | null
	city: string | null
	district: string | null
	devAddress: string | null
}) => request.post<null>("/user/uEditDevBaseData", params)

/**查询报警配置 */
export const uSelectDevReportConf = (params: {devId: string | number}) =>
	request.get<Setting.ReportConf[]>("/user/uSelectDevReportConf", params)

/**用户修改并开启报警配置 */
export const uEditOrOpenReportConf = (params: {
	devReportConfId: string
	devReportStartTime: string
	devReportEndTime: string
	devReportIntervalTime: string
	devReportTopLimit: string
}) => request.get<null>("/user/uEditOrOpenReportConf", params)

/**用户关闭报警配置 */
export const uDisableReportConf = (params: {devReportConfId: string}) =>
	request.get<null>("/user/uDisableReportConf", params)

/**用户查询标准配置 */
export const uSelectDevMsgAndStandRange = (params: {devId: string; userId: number}) =>
	request.get<Setting.StandardDataSource>("/user/uSelectDevMsgAndStandRange", params)

/**用户查询单个参数的标准配置 */
export const uSelectDevMsgAndParamStandRange = (params: {
	devId: string
	devSRId: string
	userId: number
}) =>
	request.get<Setting.ParamStandardSettingDataSource>(
		"/user/uSelectDevMsgAndParamStandRange",
		params
	)

/**用户修改合格标准 */
export const uEditDevStandRange = (params: {devSRId: number; standRange: string}) =>
	request.get<null>("/user/uEditDevStandRange", params)

/**用户关闭单个参数的合格标准 */
export const closeDevStandRange = (params: {devSRId: number}) =>
	request.get<null>("/user/closeDevStandRange", params)

/**用户开启单个参数的合格标准 */
export const openDevStandRange = (params: {devSRId: number}) =>
	request.get<null>("/user/openDevStandRange", params)

/**用户查询采集频率 */
export const uSelectDevUploadInterval = (params: {devId: number}) =>
	request.get<number>("/user/uSelectDevUploadInterval", params)

/**用户修改采集频率 */
export const uEditUploadInterval = (params: {devId: number; intervalData: number}) =>
	request.get<null>("/user/uEditUploadInterval", params)

/**用户查询控制功能 */
export const uSelectDevControl = (params: {devId: string | number}) =>
	request.get<Setting.DevControll[]>("/user/devControlFun/selectByDevId", params)
/**用户执行控制功能 */
export const exeControlCommand = (params: {controlId: number}) => {
	// console.log(params)
	return request.get<string | null>("/user/exeControlCommand", params)
}

/**发送雨水和污水控制指令 */
// export const exeControlCommand

/* 雨水和污水的开关处理 ----------------------------------------------------------------------------------------- */
/** 获取雨水开启和污水开启的状态的Api **/
// export const uSelectRainwaterAndSewageStatusApi = ()=>{
//   // request.get()
// }

/* 查询是否是设备管理者 */
export const uSelectIsManage = (userId, devId) => {
	return request.get("/user/uSelectIsManage", {
		userId: userId,
		devId: devId
	})
}
